package com.zly.action;

import javax.servlet.http.HttpServletRequest;

import org.apache.struts2.ServletActionContext;

import com.opensymphony.xwork2.ActionSupport;
import com.zly.entity.Absence;
import com.zly.entity.Dorm;
import com.zly.entity.Houseparent;
import com.zly.entity.StudentInfoManager;
import com.zly.service.DormService;
import com.zly.service.impl.DormServiceImpl;

public class DeleteAction extends ActionSupport {

	/**
	 * 反序列化
	 */
	private static final long serialVersionUID = 1L;

	private String result;
	private String resultStu;
	private String resultTower;
	private String resultAbs;
	public String getResultAbs() {
		return resultAbs;
	}

	public void setResultAbs(String resultAbs) {
		this.resultAbs = resultAbs;
	}

	public String getResultTower() {
		return resultTower;
	}

	public void setResultTower(String resultTower) {
		this.resultTower = resultTower;
	}

	public String getResultStu() {
		return resultStu;
	}

	public void setResultStu(String resultStu) {
		this.resultStu = resultStu;
	}

	public String getResult() {
		return result;
	}

	public void setResult(String result) {
		this.result = result;
	}
	/**
	 * 删除宿舍管理员
	 * @return
	 */
	public String delete() {
		HttpServletRequest request = ServletActionContext.getRequest();
		String id = request.getParameter("id");
		int idInt = Integer.parseInt(id);
		// System.out.println(idInt+"++++");
		// 调用service层实现删除
		DormService<Houseparent> dormService = new DormServiceImpl<>();
		dormService.deleteById(Houseparent.class, idInt);
		result = "1";
		return SUCCESS;
	}
	/**
	 * 删除学生
	 * @return
	 */
	public String deleteStu() {
		HttpServletRequest request = ServletActionContext.getRequest();
		String stuId = request.getParameter("stuId");
		int stuIdInt = Integer.parseInt(stuId);
//		System.out.println(stuIdInt+"++++");
		// 调用service层实现删除
		DormService<StudentInfoManager> dormService = new DormServiceImpl<>();
		dormService.deleteById(StudentInfoManager.class, stuIdInt);
		resultStu = "1";
		return SUCCESS;
	}
	/**
	 * 删除宿舍楼信息
	 * @return
	 */
	public String deleteTower() {
		HttpServletRequest request = ServletActionContext.getRequest();
		String dormId = request.getParameter("dormId");
		int dormIdInt = Integer.parseInt(dormId);
		System.out.println(dormIdInt+"++++");
		// 调用service层实现删除
		DormService<Dorm> dormService = new DormServiceImpl<>();
		dormService.deleteById(Dorm.class, dormIdInt);
		resultTower = "1";
		return SUCCESS;
	}
	/**
	 * 删除缺勤信息
	 * @return
	 */
	public String deleteAbs() {
		HttpServletRequest request = ServletActionContext.getRequest();
		String absenceId = request.getParameter("absenceId");
		int absenceIdInt = Integer.parseInt(absenceId);
		System.out.println(absenceId+"++++");
		// 调用service层实现删除
		DormService<Absence> dormService = new DormServiceImpl<>();
		dormService.deleteById(Absence.class, absenceIdInt);
		resultAbs = "1";
		return SUCCESS;
	}
}
